﻿using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestDxfDocument

{
    class ISYC_309_08
    {
        //图F.99  ISYC 309-08-法兰接触式连接的可转位刀片外螺纹车削系统
        public static void ISYC_309_08_g(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //基本参数-------------------------------------------------------------------------------------------------
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            //赋值参数--------------------------------------------------------------------------------------------------
               double sl_ = Convert.ToDouble(data["oal"]);
              double scale = Convert.ToDouble(data["scale"]);
          //  double sl_ = 68;
          //  double scale = 1;
            if (sl_ <= 67)
            {
                scale = 4;
            }
            else if (67 < sl_ && sl_ <= 75)
            {
                scale = 2.5;
            }
            else if (75 < sl_ && sl_ <= 100)
            {
                scale = 2;
            }
            else
            {
                scale = 1;
            }/*
            double dconms = 10 * scale;
            double oal = 21.32 * scale;
            double lpr = 16.44 * scale;
            double wf = 6.8 * scale;
            double pdy = 3.23 * scale;
            double pdx = 1.35 * scale;
            */
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double lpr = Convert.ToDouble(data["lpr"]) * scale;
            double wf = Convert.ToDouble(data["wf"]) * scale;
            double pdy = Convert.ToDouble(data["pdy"]) * scale;
            double pdx = Convert.ToDouble(data["pdx"]) * scale;
            double wfa = 6.58 * scale;
            //点---------------------------------------------------------------------------------------------
            //第一部分
            Vector2 p0 = new Vector2(0, 0);
            Vector2[] vis(Vector2 p)
            {
                Vector2 p1_0; Vector2 p2_0; Vector2 p3_0; Vector2 p4_0; Vector2 p5;
                p1_0 = fun.Polar(p, pi / 2, dconms / 2.0);
                p2_0 = fun.Polar(p, pi / -2, dconms / 2.0);
                p3_0 = fun.Polar(p2_0, pi, 4.2 / 19.54 * lpr);
                p4_0 = fun.Polar(p1_0, pi, fun.CalDistance(p2_0, p3_0));
                p5 = fun.Polar(p3_0, pi / 2, dconms / 12.5);
                Vector2 p6 = fun.Polar(p5, pi - 5 * pi / 180, ((oal - lpr) / Math.Cos(5 * pi / 180)) - ((0.4 / 4.96) * (oal - lpr)));
                Vector2 p7_0 = fun.Polar(fun.Polar(p5, pi / 2, fun.CalDistance(p4_0, p5) / 2.0), pi, oal - lpr);
                Vector2 p7_1 = fun.Polar(p7_0, pi / 2, dconms);
                Vector2 p7_2 = fun.Polar(p7_0, pi / -2, dconms);
                Vector2 p7_3 = fun.Polar(p6, fun.CalAngle(p5, p6) - pi / 4, dconms);
                Vector2 p7_4 = fun.Inters(p6, p7_3, p7_1, p7_2);
                Vector2 p8_0 = fun.Polar(p4_0, pi / -2, fun.CalDistance(p3_0, p5));
                Vector2 p9_0 = fun.Polar(p8_0, pi + 5 * pi / 180, fun.CalDistance(p5, p6));
                Vector2 p10_0 = fun.Polar(p9_0, (-fun.CalAngle(p6, p7_4)), fun.CalDistance(p6, p7_4));
                var polyline1 = Pus.AddPointsToLwPolyLine(p8_0, p4_0, p1_0, p2_0, p3_0, p8_0, p9_0, p10_0, p7_4, p6, p9_0, p6, p5);
                Line line2 = new Line(fun.Polar(p, pi, -p1_0.X + (oal - lpr) ), fun.Polar(p, 0, lpr ));
                line2.Lineweight = Lineweight.W25;//Lineweight指线宽
                line2.Layer = centre;//Layer指图层
                line2.LinetypeScale = 5 * scale;//指线性比例
                if (p.Y == 0)
                    line2.Linetype = Linetype.Dashed;//Linetype指是点划线还是虚线什么的
                else
                    line2.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(new EntityObject[] { line2 , polyline1 } ); //提取
                fun.PolyFill(dxf, polyline1, 0.5, contour);
                Vector2[] pj = { p1_0, p2_0, p3_0, p4_0, p5, p6, p7_4, p8_0, p9_0, p10_0 };
                return pj;
            }

            Vector2[] pj_1 = vis(p0);
            Vector2 p1 = pj_1[0];
            Vector2 p2 = pj_1[1];
            Vector2 p3 = pj_1[2];
            Vector2 p4 = pj_1[3];

            Vector2 p11 = fun.Polar(p2, pi / -2, fun.CalDistance(p1, p2) * (0.6 / 10.0));
            Vector2 p12 = fun.Polar(p1, 0, fun.CalDistance(p1, p4) * (0.57 / 3.68));
            Vector2 p13 = new Vector2(-fun.CalDistance(p1, p4) + lpr - wfa / 4.0, 0);
            Vector2 p14 = fun.Polar(p13, pi, lpr * (7.3 / 13.22));
            Vector2 p15 = fun.Polar(p13, pi / -2, (1.13 / 10.0) * dconms);
            Vector2 p16 = fun.Polar(p15, pi, (0.37 / 13.22) * lpr);
            Vector2 p17 = fun.Polar(p16, -97 * pi / 180, dconms * (1.71 / 10.0));
            Vector2 p18_1 = fun.Polar(p11, 0, lpr);
            Vector2 p18_2 = fun.Polar(p17, -112 * pi / 180, lpr);
            Vector2 p18 = fun.Inters(p11, p18_1, p17, p18_2);
            Vector2 p19 = fun.Polar(p13, pi, (2.79 / 13.22) * lpr);
            Vector2 p20 = fun.Inters(p19, fun.Polar(p19, pi / -2, dconms), p11, p18);
            Vector2 p21 = fun.Polar(p14, 0, (1.63 / 13.22) * lpr);
            Vector2 p22 = fun.Inters(p11, p18, p21, fun.Polar(p21, pi / -2, dconms));
            Vector2 p23 = fun.Polar(p21, pi, (0.92 / 13.22) * lpr);
            Vector2 p24 = fun.Inters(p11, p18, p23, fun.Polar(p23, pi / -2, dconms));
            Vector2 p25 = fun.Inters(p19, p20, p15, fun.Polar(p15, pi, dconms));
            Vector2 p26 = fun.Polar(p13, pi, (0.89 / 13.22) * lpr);
            Vector2 p27 = fun.Inters(p25, p15, p26, fun.Polar(p26, pi / -2, dconms));
            Vector2 arc1_1 = fun.Polar(p23, pi, fun.CalDistance(p11, p24) / 3.0);
            Vector2 arc1_2 = fun.Polar(arc1_1, pi - pi / 3, dconms);
            Vector2 p28_0 = fun.Polar(p13, pi, (4.5 / 13.22) * lpr);
            Vector2 p29_1 = fun.Polar(p15, pi, oal);
            Vector2 p29_2 = fun.Polar(p28_0, pi / -2, oal);
            Vector2 p29_0 = fun.Inters(p28_0, p29_2, p15, p29_1);
            Vector2 p30_0 = fun.Polar(p28_0, 0, (0.32 / 13.22) * lpr);
            Vector2 p31_0 = fun.Inters(p29_1, p15, p30_0, fun.Polar(p30_0, pi / -2, oal));

            //第二部分
            //柄部
            Vector2 p0_0 = fun.Polar(p0, pi / -2, dconms * 3);
            Vector2[] pj_2 = vis(p0_0);
            Vector2 p1_10 = pj_2[0];
            Vector2 p2_10 = pj_2[1];
            Vector2 p3_10 = pj_2[2];
            Vector2 p4_10 = pj_2[3];
            Vector2 p5_10 = pj_2[4];
            Vector2 p6_10 = pj_2[5];
            Vector2 p7_10 = pj_2[6];
            Vector2 p8_10 = pj_2[7];
            Vector2 p9_10 = pj_2[8];
            Vector2 p10_10 = pj_2[9];
            Vector2 p28 = new Vector2(-fun.CalDistance(p1, p4) + lpr-wfa/4.0 , p0_0.Y);
            Vector2 p29 = fun.Polar(p28, pi / 2, (0.67 / 10.0) * dconms);
            Vector2 p30_1 = fun.Polar(p29, pi - pi / 4, dconms);
            Vector2 p30_2 = fun.Polar(p1_10, 0, dconms);
            Vector2 p30 = fun.Inters(p1_10, p30_2, p29, p30_1);
            Vector2 p31 = fun.Polar(p2_10, pi / -6, (1 / 13.33) * lpr);
            Vector2 p32_1 = fun.Polar(p28, pi / -2, dconms);
            Vector2 p32_2 = fun.Polar(p31, 0, dconms);
            //切削部分
            Vector2 p32 = fun.Inters(p31, p32_2, p28, p32_1);
            Vector2 p33 = fun.Polar(p32, 162 * pi / 180, ((0.57 / 10.0) * dconms) / Math.Sin (18 * pi / 180));
            Vector2 p34 = new Vector2(-fun.CalDistance(p1, p4) + lpr, -wf + p0_0.Y);
            
            Vector2 []   vis1(Vector2  pp,Vector2 pp1,double i)
            {
                Vector2 p35_0 = fun.Polar(pp, -pi / 6, (wfa / 2.0*i) / Math.Sin(pi / 3));
                Vector2 p36_0 = fun.Polar(p35_0, pi, wfa * i);
                Vector2 p37_0 = fun.Polar(p36_0, pi / 3, wfa * i);
                Vector2 pp2 = fun.Inters(pp1, fun.Polar(pp1, pi + 15 * pi / 180, oal), p35_0, p36_0);
                Vector2 pp3 = fun.Polar(pp1, pi - 15 * pi / 180, fun.CalDistance(pp1, pp2));
                Vector2 pp4 = fun.Polar(pp3, pi / 2, fun.CalDistance(pp1, pp3) / 3.0);
                Vector2 pp5 = fun.Polar(pp4, 15 * pi / 180, fun.CalDistance(pp3, pp4) / 2.5);
                Vector2 pp6 = fun.Inters(pp5, fun.Polar(pp5, pi / 2, oal), p35_0, p37_0);
                var polyline1 = Pus.AddPointsToLwPolyLine(pp2, pp1, pp3, pp4, pp5, pp6);
                dxf.AddEntity(polyline1);
                fun.PolyFill(dxf, polyline1, 0.5, contour);
                Vector2[] pp7 = { pp2, pp3, pp4, pp5, pp6,p35_0 ,p36_0 ,p37_0  };
                return pp7;
            }
            Vector2[] vs = vis1(p33,p34,1);
            Vector2 vis_2 = vs[0];
            Vector2 vis_6 = vs[4];
            Vector2 p35 = vs[5];
            Vector2 p36 = vs[6];
            Vector2 p37 = vs[7];
            Vector2 p38 = fun.PointRotate(p33, vs[0], 120*pi/180);
            Vector2 p39 = fun.PointRotate(p33, vs[1], 120 * pi / 180);
            Vector2 p40 = fun.PointRotate(p33, vs[2], 120 * pi / 180);
            Vector2 p41 = fun.PointRotate(p33, vs[3], 120 * pi / 180);
            Vector2 p42 = fun.PointRotate(p33, vs[4], 120 * pi / 180);
            Vector2 p43 = fun.PointRotate(p33, p34 , 120 * pi / 180);

            Vector2 p44 = fun.PointRotate(p33, vs[0], -120 * pi / 180);
            Vector2 p45 = fun.PointRotate(p33, vs[1], -120 * pi / 180);
            Vector2 p46 = fun.PointRotate(p33, vs[2], -120 * pi / 180);
            Vector2 p47 = fun.PointRotate(p33, vs[3], -120 * pi / 180);
            Vector2 p48 = fun.PointRotate(p33, vs[4], -120 * pi / 180);
            Vector2 p49 = fun.PointRotate(p33, p34, -120 * pi / 180);
            Vector2 p50 = fun.Inters(p31, fun.Polar(p31, 0, oal), p36, p37);
            Vector2 p51 = fun.Inters(p28, fun.Polar(p28, pi / -2, oal), p35, p37);

            Vector2 p52 = fun.Inters(p7_10, fun.Polar(p7_10, pi / -2, oal), p33, fun.Polar(p33, pi + 60 * pi / 180, oal));
            Vector2 p53 = fun.Polar(p34, pi + 60 * pi / 180, fun.CalDistance(p33, p52));
            Vector2 p54 = fun.Polar(p52, fun.CalAngle(p52, p53), fun.CalDistance(p52, p53) );

            //第三部分
            Vector2[] vs_3 = vis1(p52, p54, 1.5);
            
            Vector2 p55 = vs_3[5];
            Vector2 p56 = vs_3[6];
            Vector2 p57 = vs_3[7];
            Vector2 p58 = vs_3[0];
            Vector2 p59 = vs_3[4];
            Vector2 p60 = fun.Polar(p58, pi, fun.CalDistance(p55, p58) / 2.0);
            Vector2 p61 = fun.Polar(p59, fun.CalAngle(p55, p59), fun.CalDistance(p58, p60));
            double a = fun.CalAngle(p60, p61);
            double b = fun.CalDistance(p60, p61) / 6.0;
            for (double e = 0; e < fun.CalDistance(p60, p61)+ fun.CalDistance(p60, p61) / 3.0; e += fun.CalDistance(p60, p61) / 3.0) 
            {
                Vector2 r1 = fun.Polar(p60, a, b);
                Vector2 r2= fun.Polar(r1 , a, b);
                var polyline5= Pus.AddPointsToLwPolyLine(p58, p60, r1, r2);
                if (e == 0)
                {
                     polyline5 = Pus.AddPointsToLwPolyLine(p58, p60, r1, r2);
                    polyline5.Vertexes[1].Bulge = Math.Tan((93 * pi / 180) / 4);
                    polyline5.Vertexes[2].Bulge = -Math.Tan((93 * pi / 180) / 4);
                }
                else if(e< fun.CalDistance(p60, p61)- fun.CalDistance(p60, p61) / 3.0)
                {
                     polyline5 = Pus.AddPointsToLwPolyLine( p60, r1, r2);
                    polyline5.Vertexes[0].Bulge = Math.Tan((93 * pi / 180) / 4);
                    polyline5.Vertexes[1].Bulge = -Math.Tan((93 * pi / 180) / 4);
                }    
                else
                {
                    polyline5 = Pus.AddPointsToLwPolyLine(p60, r1, r2,p59 );
                    polyline5.Vertexes[0].Bulge = Math.Tan((93 * pi / 180) / 4);
                    polyline5.Vertexes[1].Bulge = -Math.Tan((93 * pi / 180) / 4);
                }
                dxf.AddEntity(polyline5);
                fun.PolyFill(dxf, polyline5, 0.5, contour);
                p60 = r2;
            }
            
            var polyline4 = Pus.AddPointsToLwPolyLine(vis_2, p42, p41, p40, p39, p43, p38,p48,p47,p46,p45, p49, p44,vis_6) ;
            var polyline6 = Pus.AddPointsToLwPolyLine(p58, p55, p59);
            dxf.AddEntity(polyline6);
            Arc arc1 = fun.DrawArc5(p12, new Line(arc1_1, arc1_2), p14);
            var polyline2 = Pus.AddPointsToLwPolyLine(p12, p1, p11, p24, p23, p21, p22, p24, p20, p25, p29_0, p28_0,p30_0,p31_0,p30_0, p13, p15, p27, p25, p27,
                p26, p19, p20, p18, p17, p16, p15, p13, p14);
            var polyline3 = Pus.AddPointsToLwPolyLine(p50,p31,p2_10 ,p1_10,p30,p29,p51 ); 
            //    fun.PolyFill(dxf, polyline2, 0.5, contour);
            //    fun.drawBArc(dxf, arc1, 0.5, contour);
            dxf.AddEntity(new EntityObject[] { polyline2,polyline3,polyline4  
                , arc1
            });
            fun.PolyFill(dxf, polyline2, 0.5, contour);
            fun.PolyFill(dxf, polyline3, 0.5, contour);
            fun.PolyFill(dxf, polyline4, 0.5, contour);
            fun.drawBArc(dxf, arc1, 0.5, contour);
            //标注
            /* fun.dimrot1(dxf, p1, p18, 90, dc, 2, 2 * scale, 2.4 * scale, 0.9, "DCB", "", "");
            fun.jdbz2(dxf, new Line(p4, p5), new Line(p7, p8), dc, 2 * scale, 2.4 * scale, 0.9, "SIG", "", "");
            fun.Axis(dxf, fun.Polar(p0, pi + pi / 3, dc * 2), 180, -90, "Z", "X", "Y", 1 * scale, 2 * scale, 0);
            fun.Axis(dxf, p0, 180, -90, "", "", "", 1 * scale, 2 * scale, 0);
            fun.Axis(dxf, p19, 180, -90, "", "", "", 1 * scale, 2 * scale, 0);
            fun.Singlelinearrow(dxf, "CCMS", v1, 110, fun.Polar(v1, 110 * pi / 180, dc / 2.0), fun.Polar(v1, 110 * pi / 180, dc), 1.2 * scale, 1.6 * scale);
            Text txt1 = new Text("PCS", v18, 2.2 *scale , 0);
            Circle circle1 = new Circle(p0, 1.7 * 2 * scale) ;*/
            Vector2 v1 = vs_3 [0];
            Vector2 v2 = fun.Polar(p3, pi / 2, fun.CalDistance(p3, p4) / 2.0);
            Vector2 v3 = fun.Polar(p3_10, pi / 2, fun.CalDistance(p3_10, p4_10)/2.0);
            Vector2 v4 = fun.Polar(p9_10, fun.CalAngle(p9_10, p8_10), fun.CalDistance(p9_10, p8_10) / 3.0);
            Vector2 v5 = fun.Polar(p34, pi / -4, dconms);
            Vector2 v7 = fun.Polar(v2 , pi + 80 * pi / 180, 0.125 * 1.7 * scale);
            Vector2 v8 = fun.Polar(v7, pi + 80 * pi / 180, (fun.CalDistance(v2, v3) / 2.0) / Math.Cos(20 * pi / 180));
            Vector2 v9 = fun.Polar(v8, pi / -2, 0.8 * scale);
            Vector2 v10 = fun.Polar(v3, pi / 2 + 10 * pi / 180, 0.125 * 1.7 * scale);
            Vector2 v11 = fun.Polar(p19, pi / 2 + pi / 4, 0.125 * 1.7 * scale);
            Vector2 v12 = fun.Polar(v11, pi / 2 + pi / 4, dconms /2.0);
            Vector2 v13 = fun.Polar(p13, pi / -4, 0.125*1.7*scale );
            Vector2 v14 = fun.Polar(v13, pi / -4, dconms / 4.0);
            Vector2 v15 = fun.Polar(v14, pi / -2, 1.2 * scale);
            Vector2 v16 = fun.Polar(p33, pi + 15 * pi / 180, 0.125 * 1.7 * scale) ;
            Vector2 v17=fun .Polar (v16, pi + 15 * pi / 180, dconms );
            Vector2 v18 = fun.Polar(v17, pi / -2, 1.2 * scale);
            Vector2 v19 = fun.Polar(p34, pi / -4, 0.125 * 1.7 * scale);
            Vector2 v20 = fun.Polar(v19, pi / -4, dconms / 2.0);
            Vector2 v21 = fun.Polar(v20, pi / -2, 1.2 * scale);
            Vector2 v22 = fun.Polar(p54, pi / 4, 0.125 * 1.7 * scale) ;
            Vector2 v23 = fun.Polar(v22, pi / 4, dconms/2.0);
            Vector2 v24 = fun.Polar(fun.Polar(p61, pi / 2, dconms / 4.0), pi, dconms / 4.0);
            Vector2 v25 = fun.Polar(v24, pi / -2, dconms*2.5);
            Vector2 v26 = fun.Polar(v25, 0, dconms*2.5);
            Vector2 v27 = fun.Polar(v26, pi / 2, dconms*2.5);

            fun.dimrot1(dxf, p13, fun .Polar (p13,pi/-2,0.001), -90, dconms /2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "HF,HTA", "", "");
            fun.dimrot1(dxf, p4_10, p35 , 0, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "LPR,LTA,LF", "", "");
            fun.dimrot1(dxf, p3_10 , p4_10 , 90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCONMS", "", "");
            fun.dimrot1(dxf, p7_10, p35, 0, dconms/2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL", "", "");
            fun.dimrot1(dxf, p28, p34, -90, dconms *1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "WF,WTA", "", "");
            fun.dimrot1(dxf, p55, p54, -90, dconms , 2, 1.2 * scale, 1.6 * scale, 0.9, "PDX", "", "");
            fun.dimrot1(dxf, p54, fun .Polar (p54,pi/-2,0.001), -90, dconms*1.5 , 2, 1.2 * scale, 1.6 * scale, 0.9, "WF,WTA", "", "");
            fun.dimrot1(dxf, p54, p55, 180, dconms  + ((p55.Y  - p54.Y ) / 2.0), 2, 1.2 * scale, 1.6 * scale, 0.9, "PDY", "", "");
            fun.dimrot1(dxf, p54, fun .Polar (p54,pi,0.001), 180, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL,LPR,LF,LTA", "", "");
            fun.Axis(dxf, v2 , 180, 90, "Z", "Y", "", 0.125 * scale, 1.2 * scale, 0);
            fun.Axis(dxf, p19, 180, 90, "Y", "Z", "", 0.125 * scale, 1.2 * scale, 0);
            fun.Axis(dxf, v3, 180, -90, "Z", "X", "", 0.125 * scale, 1.2 * scale, 0);
            fun.Axis(dxf, p33, 180, 90, "Y", "X", "", 0.125 * scale, 1.2 * scale, 0);
            fun.Singlelinearrow(dxf, "CCMS", v4, 145, fun.Polar(v4, 145 * pi / 180, dconms / 2.0), fun.Polar(v4, 145 * pi / 180, dconms), 1.2 * scale, 1.6 * scale);
            fun.Singlelinearrow(dxf, "FDP", v5, -90, fun.Polar(v5, pi/2, dconms / 4.0), fun.Polar(v5, pi/2, dconms / 2.0), 1.2 * scale, 1.6 * scale);
            Text txt1 = new Text("PCS,MCS", v9, 1.2 * scale, 0);
            Text txt2 = new Text("CSW", v12, 1.2 * scale, 0);
            Text txt3 = new Text("CRP", v15, 1.2 * scale, 0);
            Text txt4 = new Text("CSW", v18, 1.2 * scale, 0);
            Text txt5 = new Text("CRP", v21, 1.2 * scale, 0);
            Text txt6 = new Text("CRP", v23, 1.2 * scale, 0);
            Text txt7 = new Text("A", fun .Polar (p34,pi/4, 1.7 * 0.125 * scale * 9), 1.2 * scale, 0);
            Text txt8 = new Text("A", fun .Polar (p61,pi/2,dconms /4.0) , 1.2 * scale, 0);
            Text txt9 = new Text("ISYC=309_08", fun.Polar(p4, pi / 2, dconms / 2.0), 1.2 * scale, 0) ;
            Line linev1 = new Line(v7, v8);
            Line linev2 = new Line(v9, v10);
            Line linev3 = new Line(v11, v12);
            Line linev4 = new Line(v13, v14);
            Line linev5 = new Line(v16, v17);
            Line linev6 = new Line(v19, v20);
            Line linev7 = new Line(v22, v23);
            Circle circle1 = new Circle(p13, 1.7 * 0.125 * scale);
            Circle circle2 = new Circle(p34, 1.7 * 0.125 * scale);
            Circle circle3 = new Circle(p34, 1.7 * 0.125 * scale*9);
            Circle circle4 = new Circle(p54, 1.7 * 0.125 * scale );
            var polyline7 = Pus.AddPointsToLwPolyLine(v24, v25, v26, v27, v24);
            polyline7.Layer = additionalline;//Layer指图层
            polyline7.LinetypeScale = 5 * scale ;//指线性比例
            polyline7.Linetype = Linetype.Dashed ;//Linetype指是点划线还是虚线什么的

            dxf.AddEntity(new EntityObject[] { txt1 ,txt2 ,txt3 ,txt4 ,txt5,txt6,txt7 ,txt8,txt9  
            ,linev1 ,linev2 ,linev3 ,linev4 ,linev5 ,linev6 ,linev7
            ,circle1 ,circle2 ,circle3 ,circle4 
            ,polyline7 
            });
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
dxf.Save(path);
}

        //图F.99  ISYC 309-08-法兰接触式连接的可转位刀片外螺纹车削系统
        public static void ISYC_309_08_j(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //基本参数-------------------------------------------------------------------------------------------------
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            //赋值参数--------------------------------------------------------------------------------------------------
               double sl_ = Convert.ToDouble(data["oal"]);
              double scale = Convert.ToDouble(data["scale"]);
         //   double sl_ = 68;
         //   double scale = 1;
            if (sl_ <= 67)
            {
                scale = 4;
            }
            else if (67 < sl_ && sl_ <= 75)
            {
                scale = 2.5;
            }
            else if (75 < sl_ && sl_ <= 100)
            {
                scale = 2;
            }
            else
            {
                scale = 1;
            }/*
            double dconms = 10 * scale;
            double oal = 21.32 * scale;
            double lpr = 16.44 * scale;
            double wf = 6.8 * scale;
            double pdy = 3.23 * scale;
            double pdx = 1.35 * scale;
            */
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double lpr = Convert.ToDouble(data["lpr"]) * scale;
            double wf = Convert.ToDouble(data["wf"]) * scale;
            double pdy = Convert.ToDouble(data["pdy"]) * scale;
            double pdx = Convert.ToDouble(data["pdx"]) * scale;
            double wfa = 6.58 * scale;
            //点---------------------------------------------------------------------------------------------
            //第一部分
            Vector2 p0 = new Vector2(0, 0);
            Vector2[] vis(Vector2 p)
            {
                Vector2 p1_0; Vector2 p2_0; Vector2 p3_0; Vector2 p4_0; Vector2 p5;
                p1_0 = fun.Polar(p, pi / 2, dconms / 2.0);
                p2_0 = fun.Polar(p, pi / -2, dconms / 2.0);
                p3_0 = fun.Polar(p2_0, pi, 4.2 / 19.54 * lpr);
                p4_0 = fun.Polar(p1_0, pi, fun.CalDistance(p2_0, p3_0));
                p5 = fun.Polar(p3_0, pi / 2, dconms / 12.5);
                Vector2 p6 = fun.Polar(p5, pi - 5 * pi / 180, ((oal - lpr) / Math.Cos(5 * pi / 180)) - ((0.4 / 4.96) * (oal - lpr)));
                Vector2 p7_0 = fun.Polar(fun.Polar(p5, pi / 2, fun.CalDistance(p4_0, p5) / 2.0), pi, oal - lpr);
                Vector2 p7_1 = fun.Polar(p7_0, pi / 2, dconms);
                Vector2 p7_2 = fun.Polar(p7_0, pi / -2, dconms);
                Vector2 p7_3 = fun.Polar(p6, fun.CalAngle(p5, p6) - pi / 4, dconms);
                Vector2 p7_4 = fun.Inters(p6, p7_3, p7_1, p7_2);
                Vector2 p8_0 = fun.Polar(p4_0, pi / -2, fun.CalDistance(p3_0, p5));
                Vector2 p9_0 = fun.Polar(p8_0, pi + 5 * pi / 180, fun.CalDistance(p5, p6));
                Vector2 p10_0 = fun.Polar(p9_0, (-fun.CalAngle(p6, p7_4)), fun.CalDistance(p6, p7_4));
                var polyline1 = Pus.AddPointsToLwPolyLine(p8_0, p4_0, p1_0, p2_0, p3_0, p8_0, p9_0, p10_0, p7_4, p6, p9_0, p6, p5);
                Line line2 = new Line(fun.Polar(p, pi, -p1_0.X + (oal - lpr)), fun.Polar(p, 0, lpr));
                line2.Lineweight = Lineweight.W25;//Lineweight指线宽
                line2.Layer = centre;//Layer指图层
                line2.LinetypeScale = 5 * scale;//指线性比例
                if (p.Y == 0)
                { }
                else
                {
                    line2.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                    dxf.AddEntity(new EntityObject[] { line2, polyline1 }); //提取
                    fun.PolyFill(dxf, polyline1, 0.5, contour);
                }
               
                Vector2[] pj = { p1_0, p2_0, p3_0, p4_0, p5, p6, p7_4, p8_0, p9_0, p10_0 };
                return pj;
            }

            Vector2[] pj_1 = vis(p0);
            Vector2 p1 = pj_1[0];
            Vector2 p2 = pj_1[1];
            Vector2 p3 = pj_1[2];
            Vector2 p4 = pj_1[3];

            Vector2 p11 = fun.Polar(p2, pi / -2, fun.CalDistance(p1, p2) * (0.6 / 10.0));
            Vector2 p12 = fun.Polar(p1, 0, fun.CalDistance(p1, p4) * (0.57 / 3.68));
            Vector2 p13 = new Vector2(-fun.CalDistance(p1, p4) + lpr - wfa / 4.0, 0);
            Vector2 p14 = fun.Polar(p13, pi, lpr * (7.3 / 13.22));
            Vector2 p15 = fun.Polar(p13, pi / -2, (1.13 / 10.0) * dconms);
            Vector2 p16 = fun.Polar(p15, pi, (0.37 / 13.22) * lpr);
            Vector2 p17 = fun.Polar(p16, -97 * pi / 180, dconms * (1.71 / 10.0));
            Vector2 p18_1 = fun.Polar(p11, 0, lpr);
            Vector2 p18_2 = fun.Polar(p17, -112 * pi / 180, lpr);
            Vector2 p18 = fun.Inters(p11, p18_1, p17, p18_2);
            Vector2 p19 = fun.Polar(p13, pi, (2.79 / 13.22) * lpr);
            Vector2 p20 = fun.Inters(p19, fun.Polar(p19, pi / -2, dconms), p11, p18);
            Vector2 p21 = fun.Polar(p14, 0, (1.63 / 13.22) * lpr);
            Vector2 p22 = fun.Inters(p11, p18, p21, fun.Polar(p21, pi / -2, dconms));
            Vector2 p23 = fun.Polar(p21, pi, (0.92 / 13.22) * lpr);
            Vector2 p24 = fun.Inters(p11, p18, p23, fun.Polar(p23, pi / -2, dconms));
            Vector2 p25 = fun.Inters(p19, p20, p15, fun.Polar(p15, pi, dconms));
            Vector2 p26 = fun.Polar(p13, pi, (0.89 / 13.22) * lpr);
            Vector2 p27 = fun.Inters(p25, p15, p26, fun.Polar(p26, pi / -2, dconms));
            Vector2 arc1_1 = fun.Polar(p23, pi, fun.CalDistance(p11, p24) / 3.0);
            Vector2 arc1_2 = fun.Polar(arc1_1, pi - pi / 3, dconms);
            Vector2 p28_0 = fun.Polar(p13, pi, (4.5 / 13.22) * lpr);
            Vector2 p29_1 = fun.Polar(p15, pi, oal);
            Vector2 p29_2 = fun.Polar(p28_0, pi / -2, oal);
            Vector2 p29_0 = fun.Inters(p28_0, p29_2, p15, p29_1);
            Vector2 p30_0 = fun.Polar(p28_0, 0, (0.32 / 13.22) * lpr);
            Vector2 p31_0 = fun.Inters(p29_1, p15, p30_0, fun.Polar(p30_0, pi / -2, oal));

            //第二部分
            //柄部
            Vector2 p0_0 = fun.Polar(p0, pi / -2, dconms * 3);
            Vector2[] pj_2 = vis(p0_0);
            Vector2 p1_10 = pj_2[0];
            Vector2 p2_10 = pj_2[1];
            Vector2 p3_10 = pj_2[2];
            Vector2 p4_10 = pj_2[3];
            Vector2 p5_10 = pj_2[4];
            Vector2 p6_10 = pj_2[5];
            Vector2 p7_10 = pj_2[6];
            Vector2 p8_10 = pj_2[7];
            Vector2 p9_10 = pj_2[8];
            Vector2 p10_10 = pj_2[9];
            Vector2 p28 = new Vector2(-fun.CalDistance(p1, p4) + lpr - wfa / 4.0, p0_0.Y);
            Vector2 p29 = fun.Polar(p28, pi / 2, (0.67 / 10.0) * dconms);
            Vector2 p30_1 = fun.Polar(p29, pi - pi / 4, dconms);
            Vector2 p30_2 = fun.Polar(p1_10, 0, dconms);
            Vector2 p30 = fun.Inters(p1_10, p30_2, p29, p30_1);
            Vector2 p31 = fun.Polar(p2_10, pi / -6, (1 / 13.33) * lpr);
            Vector2 p32_1 = fun.Polar(p28, pi / -2, dconms);
            Vector2 p32_2 = fun.Polar(p31, 0, dconms);
            //切削部分
            Vector2 p32 = fun.Inters(p31, p32_2, p28, p32_1);
            Vector2 p33 = fun.Polar(p32, 162 * pi / 180, ((0.57 / 10.0) * dconms) / Math.Sin(18 * pi / 180));
            Vector2 p34 = new Vector2(-fun.CalDistance(p1, p4) + lpr, -wf + p0_0.Y);

            Vector2[] vis1(Vector2 pp, Vector2 pp1, double i)
            {
                Vector2 p35_0 = fun.Polar(pp, -pi / 6, (wfa / 2.0 * i) / Math.Sin(pi / 3));
                Vector2 p36_0 = fun.Polar(p35_0, pi, wfa * i);
                Vector2 p37_0 = fun.Polar(p36_0, pi / 3, wfa * i);
                Vector2 pp2 = fun.Inters(pp1, fun.Polar(pp1, pi + 15 * pi / 180, oal), p35_0, p36_0);
                Vector2 pp3 = fun.Polar(pp1, pi - 15 * pi / 180, fun.CalDistance(pp1, pp2));
                Vector2 pp4 = fun.Polar(pp3, pi / 2, fun.CalDistance(pp1, pp3) / 3.0);
                Vector2 pp5 = fun.Polar(pp4, 15 * pi / 180, fun.CalDistance(pp3, pp4) / 2.5);
                Vector2 pp6 = fun.Inters(pp5, fun.Polar(pp5, pi / 2, oal), p35_0, p37_0);
                var polyline1 = Pus.AddPointsToLwPolyLine(pp2, pp1, pp3, pp4, pp5, pp6);
                if(pp1==p34)
                {
                    dxf.AddEntity(polyline1);
                    fun.PolyFill(dxf, polyline1, 0.5, contour);

                }
                else
                {}
                Vector2[] pp7 = { pp2, pp3, pp4, pp5, pp6, p35_0, p36_0, p37_0 };
                return pp7;
            }
            Vector2[] vs = vis1(p33, p34, 1);
            Vector2 vis_2 = vs[0];
            Vector2 vis_6 = vs[4];
            Vector2 p35 = vs[5];
            Vector2 p36 = vs[6];
            Vector2 p37 = vs[7];
            Vector2 p38 = fun.PointRotate(p33, vs[0], 120 * pi / 180);
            Vector2 p39 = fun.PointRotate(p33, vs[1], 120 * pi / 180);
            Vector2 p40 = fun.PointRotate(p33, vs[2], 120 * pi / 180);
            Vector2 p41 = fun.PointRotate(p33, vs[3], 120 * pi / 180);
            Vector2 p42 = fun.PointRotate(p33, vs[4], 120 * pi / 180);
            Vector2 p43 = fun.PointRotate(p33, p34, 120 * pi / 180);

            Vector2 p44 = fun.PointRotate(p33, vs[0], -120 * pi / 180);
            Vector2 p45 = fun.PointRotate(p33, vs[1], -120 * pi / 180);
            Vector2 p46 = fun.PointRotate(p33, vs[2], -120 * pi / 180);
            Vector2 p47 = fun.PointRotate(p33, vs[3], -120 * pi / 180);
            Vector2 p48 = fun.PointRotate(p33, vs[4], -120 * pi / 180);
            Vector2 p49 = fun.PointRotate(p33, p34, -120 * pi / 180);
            Vector2 p50 = fun.Inters(p31, fun.Polar(p31, 0, oal), p36, p37);
            Vector2 p51 = fun.Inters(p28, fun.Polar(p28, pi / -2, oal), p35, p37);

            Vector2 p52 = fun.Inters(p7_10, fun.Polar(p7_10, pi / -2, oal), p33, fun.Polar(p33, pi + 60 * pi / 180, oal));
            Vector2 p53 = fun.Polar(p34, pi + 60 * pi / 180, fun.CalDistance(p33, p52));
            Vector2 p54 = fun.Polar(p52, fun.CalAngle(p52, p53), fun.CalDistance(p52, p53));

            //第三部分
            Vector2[] vs_3 = vis1(p52, p54, 1.5);

            Vector2 p55 = vs_3[5];
            Vector2 p56 = vs_3[6];
            Vector2 p57 = vs_3[7];
            Vector2 p58 = vs_3[0];
            Vector2 p59 = vs_3[4];
            Vector2 p60 = fun.Polar(p58, pi, fun.CalDistance(p55, p58) / 2.0);
            Vector2 p61 = fun.Polar(p59, fun.CalAngle(p55, p59), fun.CalDistance(p58, p60));
            double a = fun.CalAngle(p60, p61);
            double b = fun.CalDistance(p60, p61) / 6.0;
            for (double e = 0; e < fun.CalDistance(p60, p61) + fun.CalDistance(p60, p61) / 3.0; e += fun.CalDistance(p60, p61) / 3.0)
            {
                Vector2 r1 = fun.Polar(p60, a, b);
                Vector2 r2 = fun.Polar(r1, a, b);
                var polyline5 = Pus.AddPointsToLwPolyLine(p58, p60, r1, r2);
                if (e == 0)
                {
                    polyline5 = Pus.AddPointsToLwPolyLine(p58, p60, r1, r2);
                    polyline5.Vertexes[1].Bulge = Math.Tan((93 * pi / 180) / 4);
                    polyline5.Vertexes[2].Bulge = -Math.Tan((93 * pi / 180) / 4);
                }
                else if (e < fun.CalDistance(p60, p61) - fun.CalDistance(p60, p61) / 3.0)
                {
                    polyline5 = Pus.AddPointsToLwPolyLine(p60, r1, r2);
                    polyline5.Vertexes[0].Bulge = Math.Tan((93 * pi / 180) / 4);
                    polyline5.Vertexes[1].Bulge = -Math.Tan((93 * pi / 180) / 4);
                }
                else
                {
                    polyline5 = Pus.AddPointsToLwPolyLine(p60, r1, r2, p59);
                    polyline5.Vertexes[0].Bulge = Math.Tan((93 * pi / 180) / 4);
                    polyline5.Vertexes[1].Bulge = -Math.Tan((93 * pi / 180) / 4);
                }
                //dxf.AddEntity(polyline5);
                p60 = r2;
            }

            var polyline4 = Pus.AddPointsToLwPolyLine(vis_2, p42, p41, p40, p39, p43, p38, p48, p47, p46, p45, p49, p44, vis_6);
            var polyline6 = Pus.AddPointsToLwPolyLine(p58, p55, p59);
            Arc arc1 = fun.DrawArc5(p12, new Line(arc1_1, arc1_2), p14);
            var polyline2 = Pus.AddPointsToLwPolyLine(p12, p1, p11, p24, p23, p21, p22, p24, p20, p25, p29_0, p28_0, p30_0, p31_0, p30_0, p13, p15, p27, p25, p27,
                p26, p19, p20, p18, p17, p16, p15, p13, p14);
            var polyline3 = Pus.AddPointsToLwPolyLine(p50, p31, p2_10, p1_10, p30, p29, p51);
           /*    fun.PolyFill(dxf, polyline2, 0.5, contour);
                fun.drawBArc(dxf, arc1, 0.5, contour);
            dxf.AddEntity(new EntityObject[] { polyline2,polyline3,polyline4
                , arc1
            });*/
            fun.PolyFill(dxf, polyline3, 0.5, contour);
            fun.PolyFill(dxf, polyline4, 0.5, contour);
            //标注
            /* fun.dimrot1(dxf, p1, p18, 90, dc, 2, 2 * scale, 2.4 * scale, 0.9, "DCB", "", "");
            fun.jdbz2(dxf, new Line(p4, p5), new Line(p7, p8), dc, 2 * scale, 2.4 * scale, 0.9, "SIG", "", "");
            fun.Axis(dxf, fun.Polar(p0, pi + pi / 3, dc * 2), 180, -90, "Z", "X", "Y", 1 * scale, 2 * scale, 0);
            fun.Axis(dxf, p0, 180, -90, "", "", "", 1 * scale, 2 * scale, 0);
            fun.Axis(dxf, p19, 180, -90, "", "", "", 1 * scale, 2 * scale, 0);
            fun.Singlelinearrow(dxf, "CCMS", v1, 110, fun.Polar(v1, 110 * pi / 180, dc / 2.0), fun.Polar(v1, 110 * pi / 180, dc), 1.2 * scale, 1.6 * scale);
            Text txt1 = new Text("PCS", v18, 2.2 *scale , 0);
            Circle circle1 = new Circle(p0, 1.7 * 2 * scale) ;*/
            Vector2 v1 = vs_3[0];
            Vector2 v2 = fun.Polar(p3, pi / 2, fun.CalDistance(p3, p4) / 2.0);
            Vector2 v3 = fun.Polar(p3_10, pi / 2, fun.CalDistance(p3_10, p4_10) / 2.0);
            Vector2 v4 = fun.Polar(p9_10, fun.CalAngle(p9_10, p8_10), fun.CalDistance(p9_10, p8_10) / 3.0);
            Vector2 v5 = fun.Polar(p34, pi / -4, dconms);
            Vector2 v7 = fun.Polar(v2, pi + 80 * pi / 180, 0.125 * 1.7 * scale);
            Vector2 v8 = fun.Polar(v7, pi + 80 * pi / 180, (fun.CalDistance(v2, v3) / 2.0) / Math.Cos(20 * pi / 180));
            Vector2 v9 = fun.Polar(v8, pi / -2, 0.8 * scale);
            Vector2 v10 = fun.Polar(v3, pi / 2 + 10 * pi / 180, 0.125 * 1.7 * scale);
            Vector2 v11 = fun.Polar(p19, pi / 2 + pi / 4, 0.125 * 1.7 * scale);
            Vector2 v12 = fun.Polar(v11, pi / 2 + pi / 4, dconms / 2.0);
            Vector2 v13 = fun.Polar(p13, pi / -4, 0.125 * 1.7 * scale);
            Vector2 v14 = fun.Polar(v13, pi / -4, dconms / 4.0);
            Vector2 v15 = fun.Polar(v14, pi / -2, 1.2 * scale);
            Vector2 v16 = fun.Polar(p33, pi + 15 * pi / 180, 0.125 * 1.7 * scale);
            Vector2 v17 = fun.Polar(v16, pi + 15 * pi / 180, dconms);
            Vector2 v18 = fun.Polar(v17, pi / -2, 1.2 * scale);
            Vector2 v19 = fun.Polar(p34, pi / -4, 0.125 * 1.7 * scale);
            Vector2 v20 = fun.Polar(v19, pi / -4, dconms / 2.0);
            Vector2 v21 = fun.Polar(v20, pi / -2, 1.2 * scale);
            Vector2 v22 = fun.Polar(p54, pi / 4, 0.125 * 1.7 * scale);
            Vector2 v23 = fun.Polar(v22, pi / 4, dconms / 2.0);
            Vector2 v24 = fun.Polar(fun.Polar(p61, pi / 2, dconms / 4.0), pi, dconms / 4.0);
            Vector2 v25 = fun.Polar(v24, pi / -2, dconms * 2.5);
            Vector2 v26 = fun.Polar(v25, 0, dconms * 2.5);
            Vector2 v27 = fun.Polar(v26, pi / 2, dconms * 2.5);

           // fun.dimrot1(dxf, p13, fun.Polar(p13, pi / -2, 0.001), -90, dconms / 2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "HF,HTA", "", "");
            fun.dimrot1(dxf, p4_10, p35, 0, dconms*1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "LF,LPR", "", "");
            fun.dimrot1(dxf, p3_10, p4_10, 90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCON", "", "");
            fun.dimrot1(dxf, p7_10, p35, 0, dconms *2.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL", "", "");
            fun.dimrot1(dxf, p28, p35, -90, dconms * 1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "WF", "", "");
            fun.dimrot1(dxf, p2_10, p35, 180, dconms , 2, 1.2 * scale, 1.6 * scale, 0.9, "LH", "", "");
            fun.dimrot1(dxf, p35, p34, -90, dconms , 2, 1.2 * scale, 1.6 * scale, 0.9, "PDY", "", "");
            fun.dimrot1(dxf, p35, p34, 180, dconms/2.0 , 2, 1.2 * scale, 1.6 * scale, 0.9, "PDX", "", "");
            /* fun.dimrot1(dxf, p55, p54, -90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "PDX", "", "");
             fun.dimrot1(dxf, p54, fun.Polar(p54, pi / -2, 0.001), -90, dconms * 1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "WF,WTA", "", "");
             fun.dimrot1(dxf, p54, p55, 180, dconms + ((p55.Y - p54.Y) / 2.0), 2, 1.2 * scale, 1.6 * scale, 0.9, "PDY", "", "");
             fun.dimrot1(dxf, p54, fun.Polar(p54, pi, 0.001), 180, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL,LPR,LF,LTA", "", "");
          */
            fun.Singlelinearrow(dxf, "CCTMS,CCFMS,CZCMS", v4, 145, fun.Polar(v4, 145 * pi / 180, dconms / 2.0), fun.Polar(v4, 145 * pi / 180, dconms), 1.2 * scale, 1.6 * scale);
            Text txt1 = new Text("PCS,MCS", v9, 1.2 * scale, 0);
            Text txt2 = new Text("CSW", v12, 1.2 * scale, 0);
            Text txt3 = new Text("CRP", v15, 1.2 * scale, 0);
            Text txt4 = new Text("CSW", v18, 1.2 * scale, 0);
            Text txt5 = new Text("CRP", v21, 1.2 * scale, 0);
            Text txt6 = new Text("CRP", v23, 1.2 * scale, 0);
            Text txt7 = new Text("A", fun.Polar(p34, pi / 4, 1.7 * 0.125 * scale * 9), 1.2 * scale, 0);
            Text txt8 = new Text("A", fun.Polar(p61, pi / 2, dconms / 4.0), 1.2 * scale, 0);
            Text txt9 = new Text("ISYC=309_08", fun.Polar(p4, pi / 2, dconms / 2.0), 1.2 * scale, 0);
            Line linev1 = new Line(v7, v8);
            Line linev2 = new Line(v9, v10);
            Line linev3 = new Line(v11, v12);
            Line linev4 = new Line(v13, v14);
            Line linev5 = new Line(v16, v17);
            Line linev6 = new Line(v19, v20);
            Line linev7 = new Line(v22, v23);
            Circle circle1 = new Circle(p13, 1.7 * 0.125 * scale);
            Circle circle2 = new Circle(p34, 1.7 * 0.125 * scale);
            Circle circle3 = new Circle(p34, 1.7 * 0.125 * scale * 9);
            Circle circle4 = new Circle(p54, 1.7 * 0.125 * scale);
            var polyline7 = Pus.AddPointsToLwPolyLine(v24, v25, v26, v27, v24);
            polyline7.Layer = additionalline;//Layer指图层
            polyline7.LinetypeScale = 5 * scale;//指线性比例
            polyline7.Linetype = Linetype.Dashed;//Linetype指是点划线还是虚线什么的

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}